/*
 * Pipe.cpp
 *
 *  Created on: 20 sep 2010
 *      Author: Juan
 */

#include "Pipe.h"

Pipe::Pipe()
{
	commands = new list<Command*>();
}

bool Pipe::hasCommands() {
	return commands->size() > 0;
}

int Pipe::countCommands() {
	return commands->size();
}

void Pipe::addCommand(Command* c) {
	commands->push_back( c );
}

list<Command*>* Pipe::getCommands() {
	return commands;
}

Pipe::~Pipe()
{
 	list<Command*>::iterator theIterator;
	 for( theIterator = commands->begin(); theIterator != commands->end(); theIterator++ )
	 {
	 	delete(*theIterator);
	 }
	delete commands;
}

Command* Pipe::popCommand()
{
	Command* returnCommand = commands->back();
	commands->pop_back();
	return returnCommand;
}
